local pingxi = fk.CreateSkill{
  name = "wk_heg__pingxi",
}

Fk:loadTranslationTable{
  ["wk_heg__pingxi"] = "平袭",
  [":wk_heg__pingxi"] = "当你于回合内使用【杀】或普通锦囊牌指定目标后，若你的手牌数等于你本回合使用过的牌数，你可以对其中一名手牌数等于你的角色造成1点伤害。",

  ["$wk_heg__pingxi1"] = "",
  ["$wk_heg__pingxi2"] = "",
}

pingxi:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(pingxi.name) and data.firstTarget and player.room.current == player and (data.card.type == Card.TypeBasic or data.card:isCommonTrick())
      and table.find(data.use.tos, function(p) return p ~= player and not p.dead and p:getHandcardNum() == player:getHandcardNum() end) 
      and #player.room.logic:getEventsOfScope(GameEvent.UseCard, 999, function (e)
        return e.data.from == player
      end, Player.HistoryTurn) == player:getHandcardNum()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(data.use.tos, function(p)
      return p ~= player and not p.dead and p:getHandcardNum() == player:getHandcardNum()
    end)
    local to = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#qingshid-choose",
      skill_name = pingxi.name,
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:damage{
      from = player,
      to = event:getCostData(self).tos[1],
      damage = 1,
      skillName = pingxi.name,
    }
  end,
})

return pingxi